unit RelatorioRequisicaoMercadoria;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, UrelatorioBase, RLPDFFilter, RLXLSFilter, RLFilters,
  RLHTMLFilter, RLDraftFilter, DB, DBTables, RLReport, StdCtrls, ExtCtrls,
  Buttons;

type
  TFrelatorioRequisicaoMercadoria = class(TFrelatorioBase)
    RLBand2: TRLBand;
    RLLabel1: TRLLabel;
    RLLabel2: TRLLabel;
    RLLabel3: TRLLabel;
    RLLabel4: TRLLabel;
    RLLabel5: TRLLabel;
    RLLabel6: TRLLabel;
    RLLabel7: TRLLabel;
    RLDraw1: TRLDraw;
    RLBand3: TRLBand;
    RLDBText2: TRLDBText;
    RLDBText3: TRLDBText;
    RLDBText4: TRLDBText;
    RLDBText5: TRLDBText;
    RLDBText6: TRLDBText;
    RLDBText7: TRLDBText;
    rlValorTotal: TRLDBText;
    RLBand4: TRLBand;
    RLDraw3: TRLDraw;
    RLDraw4: TRLDraw;
    RLDraw5: TRLDraw;
    RLLabel8: TRLLabel;
    RLLabel9: TRLLabel;
    RLLabel10: TRLLabel;
    QPesquisaREQ_CODIGO: TIntegerField;
    QPesquisaREQ_DATA: TDateTimeField;
    QPesquisaREQ_SOLICITANTE_DESC: TStringField;
    QPesquisaREQ_NTALAO: TStringField;
    QPesquisaREQ_ORDEM_SERVICO: TStringField;
    QPesquisaREQ_ULTIMA_VALIDACAO: TDateTimeField;
    QPesquisaTIPO_REQ_DESC: TStringField;
    QPesquisaDESCRICAO: TStringField;
    QPesquisaITENS_REQ_PRODCODIGO: TIntegerField;
    QPesquisaITENS_REQ_PROD_DESC: TStringField;
    QPesquisaPROD_UNIDSAIDA: TStringField;
    QPesquisaPROD_LOCALIZACAO: TStringField;
    QPesquisaITENS_REQ_DATA_VALIDACAO: TDateTimeField;
    QPesquisaVR_TOTAL_REQUISITADO: TFloatField;
    QPesquisaVR_TOTAL_ATENDIDO: TFloatField;
    QPesquisaITENS_REQ_VALIDACAO: TStringField;
    RLLabel11: TRLLabel;
    RLLabel12: TRLLabel;
    RLLabel13: TRLLabel;
    QPesquisaUSUARIO_AUTERACAO: TStringField;
    QPesquisaREQ_AUTORIZANTE_DESC: TStringField;
    QPesquisaREQ_AUTORIZADA: TStringField;
    QPesquisaITENS_REQ_QUANTIDADE: TFloatField;
    QPesquisaITENS_REQ_QTD_ATENDIDA: TFloatField;
    rlTotal: TRLDBResult;
    RLLabel14: TRLLabel;
    QPesquisaCHASSI: TStringField;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure RLBand3BeforePrint(Sender: TObject; var PrintIt: Boolean);
    procedure RLBand4BeforePrint(Sender: TObject; var PrintIt: Boolean);
    procedure RLReportBeforePrint(Sender: TObject; var PrintIt: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  FrelatorioRequisicaoMercadoria: TFrelatorioRequisicaoMercadoria;

implementation

uses UGestao, UGeral, CadastroRequisicao;

{$R *.dfm}

procedure TFrelatorioRequisicaoMercadoria.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
  inherited;
  {FrelatorioRequisicaoMercadoria.Release;
  FrelatorioRequisicaoMercadoria := Nil;}
end;

procedure TFrelatorioRequisicaoMercadoria.RLBand3BeforePrint(
  Sender: TObject; var PrintIt: Boolean);
begin
  inherited;

  if dsPesquisa.DataSet.FieldByName('ITENS_REQ_VALIDACAO').AsString = 'S' then
  begin

    rlValorTotal.DataField := 'VR_TOTAL_ATENDIDO';
    rlTotal.DataField      := 'VR_TOTAL_ATENDIDO';

  end else begin

    rlValorTotal.DataField := 'VR_TOTAL_REQUISITADO';
    rlTotal.DataField      := 'VR_TOTAL_REQUISITADO';

  end;

end;

procedure TFrelatorioRequisicaoMercadoria.RLBand4BeforePrint(
  Sender: TObject; var PrintIt: Boolean);
begin
  inherited;

 RLLabel11.Caption := dsPesquisa.DataSet.FieldByName('REQ_SOLICITANTE_DESC').AsString;
 RLLabel12.Caption := dsPesquisa.DataSet.FieldByName('USUARIO_AUTERACAO').AsString;

 if (dsPesquisa.DataSet.FieldByName('REQ_AUTORIZADA').AsString = 'S') then
    begin
     RLLabel13.Caption :=dsPesquisa.DataSet.FieldByName('REQ_AUTORIZANTE_DESC').AsString;
    end;
end;

procedure TFrelatorioRequisicaoMercadoria.RLReportBeforePrint(
  Sender: TObject; var PrintIt: Boolean);
begin
  inherited;
  RLBand1.height := 66;

end;

end.
